<?php
/**
 * 员工工资模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;

class BasicSalary extends Model
{
    use SoftDelete;
    public $softDelete = true;
    protected $name = 'basic_salary';
    protected $autoWriteTimestamp = true;

    //可搜索字段
    protected $searchField = [];
    protected $whereField = ['staff_id','department_id'];

    //是否启用获取器
    public function getStatusTextAttr($value, $data)
    {
        return self::BOOLEAN_TEXT[$data['status']];
    }


    //附件获取器
    public function getFileAttr($value)
    {
        return json_decode($value, true);
    }

//附件修改器
    public function setFileAttr($value)
    {
        return json_encode($value);
    }
    //关联员工表
    public function staff()
    {
        return $this->belongsTo(Staff::class);
    }

    //关联职位表
    public function department()
    {
        return $this->belongsTo(Department::class);
    }


    public function salaryLog()
    {
        return $this->hasMany('SalaryLog','staff_id','staff_id');
    }
    public function insure()
    {
        return $this->belongsTo('insure');
    }
}
